﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Client;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.TestManagement.Client;

namespace TestPlanWordWriter.Common
{
    public class TfsGateway
    {
        public static WorkItem GetWorkItem(TfsTeamProjectCollection tpc, int workItemId)
        {
            WorkItemStore wiStore = tpc.GetService<WorkItemStore>();
            WorkItem wi = wiStore.GetWorkItem(workItemId);

            return wi;
        }

        public static ITestPlanCollection GetTestPlans(TfsTeamProjectCollection tpc, string teamProjectName)
        {
            ITestManagementService test_service = 
                (ITestManagementService)tpc.GetService(typeof(ITestManagementService));
            ITestManagementTeamProject testProject = test_service.GetTeamProject(teamProjectName);

            ITestPlanCollection testPlans = testProject.TestPlans.Query("SELECT * FROM TestPlan");
            return testPlans;
        }
    }
}
